package logic

import (
	"context"
	"user/models/mysql"

	"user/internal/svc"
	"user/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowLogic {
	return &ShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ShowLogic) Show(in *user.ShowRequest) (*user.ShowResponse, error) {
	// todo: add your logic here and delete this line

	var Show mysql.House
	mysql.DB.Debug().Model(&Show).Where("id = ?", in.Id).Find(&Show)

	return &user.ShowResponse{
		Address: Show.Address,
		Area:    Show.Area,
		Rent:    int64(Show.Rent),
		Id:      int64(Show.ID),
	}, nil
}
